/*
 * Created on 07-feb-2005
 *
 * TODO To change the template for this generated file go to
 * Window - Preferences - Java - Code Style - Code Templates
 */
package com.juanfrivaldes.cio2005.gestion;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

/**
 * @author root
 * 
 * TODO To change the template for this generated type comment go to Window -
 * Preferences - Java - Code Style - Code Templates
 */
public class EnviarConfirmacionesAction extends GestionAction {

	private static Log log = LogFactory.getLog(EnviarConfirmacionesAction.class);



	/*
	 * (non-Javadoc)
	 * 
	 * @see com.juanfrivaldes.cio2005.web.BaseAction#protectedExecute(org.apache.struts.action.ActionMapping,
	 *      org.apache.struts.action.ActionForm,
	 *      javax.servlet.http.HttpServletRequest,
	 *      javax.servlet.http.HttpServletResponse)
	 */
	protected ActionForward protectedExecute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {

		if(request.getParameter("tipo").equals("final")){

			log.trace("Se pide confirmar las finales");
			this.getCio2005().sendMailConfirmacionFinal((List)request.getSession(false).getAttribute("finalesCon"));
			request.getSession(false).setAttribute("finalesCon", null);
			request.getSession(false).setAttribute("nFinalesCon", null);
			log.trace("Enviadas confirmaciones a las finales.");
		}
		else{
			log.trace("Se pide confirmar los resumenes");
			this.getCio2005().sendMailConfirmacion((List)request.getSession(false).getAttribute("resumenes"));
			request.getSession(false).setAttribute("resumenesCon", null);
			request.getSession(false).setAttribute("nResumenesCon", null);
			log.trace("Enviadas confirmaciones a los resumenes.");
		}
		
		return mapping.findForward("success");
	}

}
